//
//  AYHomeCore.swift
//  AYHome
//
//  Created by amg on 2021/4/6.
//

import Foundation

/// 本模块的名称， 本模块的storyboard 名称必须 与模块名称相同 ,静态资源的加载回用到
let modularName = "AYHome"

public  class  AYHomeCore {
    
    public static var sharedInstance :  AYHomeCore {
        struct Static {
            static let instance :  AYHomeCore =  AYHomeCore()
        }
        return Static.instance
    }
    
    ///storyboard
    public static var storyboard:UIStoryboard {
        get {
            return UIStoryboard(name: modularName, bundle:  AYHomeCore.bundle)
        }
    }

    ///供主App调用使用
    public static var homeVc:UIViewController {
        get {
            return   AYHomeCore.storyboard.instantiateViewController(withIdentifier: "AYHomeVc")
        }
    }
    
    public static var productVc:UIViewController {
        get {
            return   AYHomeCore.storyboard.instantiateViewController(withIdentifier: "AYProductVc")
        }
    }
    
    ///供其他模块使用
    public static var bundle:Bundle? {
        get {
            guard let bundleURL = Bundle(for: AYHomeCore.self).url(forResource: modularName, withExtension: "bundle") else {
                return nil
            }
            guard let bundle = Bundle(url: bundleURL) else {
                return nil
            }
            return bundle
        }
    }
}
